﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LightSwitch;
namespace LightSwitchApplication
{
    public partial class Region
    {
        partial void TotalRaiting_Compute(ref double result)
        {
            var allcount = Locations.Count();
            if (allcount == 0)
            {
                result = 3;
                return;
            }
            var allrates = Locations.Sum(item => item.TotalRating);
            result = (double) allrates / (double) allcount;
        }

        partial void FishCount_Compute(ref int result)
        {
            result = Locations.SelectMany(item => item.FishLocations).Select(item => item.Fish).Distinct().Count();
        }
    }
}
